package com.vogue.supplymall.payment.dto;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 订单支付状态查询结果封装参数
 * 
 * @author 崔岳
 *
 */
public class PayQueryResultParameter extends BaseResultParameter {
	
    public static final Logger LOGGER_PAYQUERYRESULTPARAMETER = LoggerFactory.getLogger(PayQueryResultParameter.class);
    
	private static final long serialVersionUID = 3088504527905090435L;

	@SuppressWarnings("unchecked")
    public PayQueryResultData getData() {
	    try {
            PayQueryResultData obj = PayQueryResultData.class.newInstance();
            org.apache.commons.beanutils.BeanUtils.populate(obj, (Map<String, ? extends Object>) data);
            if (((Map<String, ? extends Object>) data).get("payorderInfo") != null) {
                obj.setPayorderInfo((Map)((Map<String, ? extends Object>) data).get("payorderInfo"));
            }
            return obj;
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
            LOGGER_PAYQUERYRESULTPARAMETER.error("订单支付状态查询结果封装参数异常：{}", e.getMessage());
        } 
		return null;
	}

/*	public void setData(PayQueryResultData data) {
		this.data = data;
	}*/
	
	public void setData(Map<String, ? extends Object> data) {
        try {
            PayQueryResultData obj = PayQueryResultData.class.newInstance();
            org.apache.commons.beanutils.BeanUtils.populate(obj, (Map<String, ? extends Object>) data);
            this.data = obj;
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
            LOGGER_PAYQUERYRESULTPARAMETER.error("支付订单明细对象转化异常：{}", e.getMessage());
        } 
    }
}
